<%@ page language="java" import="java.util.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<script src='<%=basePath%>common/uploadify/jquery-1.5.1.min.js'></script> 
<script src='<%=basePath%>common/uploadify/swfobject.js'></script>
<script src='<%=basePath%>common/uploadify/jquery.uploadify.v2.1.4.min.js'></script>
<script src='<%=basePath%>thirtpart/jquery/jquery.blockUI.js'></script>
<script  src="<%=basePath %>common/javascript/common.js"></script>

<link rel="stylesheet" type="text/css" href="<%=basePath %>app/css/layout.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>common/uploadify/uploadify.css" />

<style>.tac{text-align:center}</style>
<script>
$(document).ready(function() {
  $('#file_upload').uploadify({
    'uploader'  : '<%=basePath%>common/uploadify/uploadify.swf',
    'script'    : '<%=basePath %>data/executebookimport.do',
    'cancelImg' : '<%=basePath%>common/uploadify/cancel.png',
    'folder'    : '<%=basePath%>upload',
    'queueID'   : 'fileQueue',
    'fileDataName':'importfile',
    'auto'      : false,
    'muti'     : false,
    'multi': false, 
	'buttonImg' : '<%=basePath%>common/uploadify/selectfile.gif',  
	'fileExt'        : '*.xls',   
    'fileDesc'       : '请选择xls文件(*.xls)', 
    onComplete: function (event, queueID, fileObj, response, data) {
   		 $.unblockUI();
   		 $('#uploader_message').text(response); 
   		window.parent.booklist.frameElement.src = "<%=basePath%>data/bookList.do"; 	
   		alert('古籍文献数据文件上传成功,请在数据导入模块执行数据导入操作!');
   　},
   	onError: function(event, queueID, fileObj) {    
   	     $.unblockUI();  
		alert("数据导入失败！");
    },
    onOpen  : function(event,ID,fileObj) {
       $.blockUI();  
    } 
    
  });
  
  $('#pdf_upload').uploadify({
    'uploader'  : '<%=basePath%>common/uploadify/uploadify.swf',
    'script'    : '<%=basePath %>data/pdfupload.do', 
    'cancelImg' : '<%=basePath%>common/uploadify/cancel.png',
    'folder'    : '<%=basePath%>upload',
    'queueID'   : 'fileQueue_pdf',
    'fileDataName':'pdffile',
    'auto'      : false,
    'muti'     : false,
    'multi': false, 
    'method'         : 'GET', 
	'buttonImg' : '<%=basePath%>common/uploadify/selectfile.gif',  
	'fileExt'        : '*.pdf',   
    'fileDesc'       : '请选择PDF文件(*.pdf)', 
     onSelect : function(event,queueId,fileObj,data){
    	var idselectedstr = window.parent.booklist.getSelectPaper();
    	var selectedId = "";  
    	if(idselectedstr == ""){
	    	alert("请先选择要上传原文的文献!"); 
	    	$('#fileQueue_pdf').uploadifyClearQueue(); 
	    	return;
	    }else{
	    	var temp = idselectedstr.split(','); 
	    	if(temp.length>2){
	    		alert("只能选择一篇文献上传原文!"); 
	    		$('#fileQueue_pdf').uploadifyClearQueue();
	    		return; 
	    	}else{ 
	    	    selectedId = idselectedstr.substr(0,idselectedstr.length-1);
	    		var url = '<%=basePath%>data/pdfupload.do?paperid='+selectedId; 
	    		document.getElementById("paperid").value=selectedId; 
	    		//alert($('#paperid').val());
	    		$('#pdf_upload').uploadifySettings('scriptData',{'paperid':$('#paperid').val()});  
        	 	//$("#uploadify").uploadifySettings('script',url); 
	    	} 
	    }     
	      
    },
    onComplete: function (event, queueID, fileObj, response, data) {
   		 $.unblockUI();
   		 //$('#uploader_pdf').text(response); 
   		 alert(response);
   		 //window.parent.booklist.frameElement.src = "<%=basePath%>data/bookList.do"; 	
   		 window.parent.booklist.displayAttchImg($('#paperid').val());
   　},
   	onError: function(event, queueID, fileObj) { 
   	    $.unblockUI();     
		alert("数据上传失败！");
    },
    onOpen  : function(event,ID,fileObj) {
       $.blockUI();  
    } 
    
  });
});
 
 
 </script>
</head>
<body>
 
    <table border="0" cellspacing="0" align=center cellpadding="0" class="list" style="width:97%">
      <tr>
        <th   style="text-align:center;  font-size:16px;">书籍文献数据导入</th>
      </tr>
      <tr>
      	<td>
      		<div id="fileQueue" align="center"> 
              <input id="file_upload" name="file_upload" type="file" />	&nbsp;&nbsp;
              
              <input type="button" onclick="jQuery('#file_upload').uploadifyUpload()" value="开始上传" class="butto"/> 
              <input type="button" onclick="jQuery('#file_upload').uploadifyClearQueue()" value="取消上传" class="butto"/>
            </div>
      	</td>
      	</tr>
      	<tr>
      	<td>
      		<font size=4 color=red> <span id="uploader_message"></span></font>
      	</td>
       </tr>
      	<tr>
      	<td>
      		<font color=red>导入前请下载标准的导入模板！</font><a href="javaScript:onclick=openwindow('<%=basePath %>app/书籍文献导入标准格式.xls','0','0','');">书籍导入表格模板</a> 
      	</td>
      </tr>
    </table>
    <br>
    </br>
    <br>
    </br>
      <table border="0" cellspacing="0" align=center cellpadding="0" class="list" style="width:97%">
      <tr>
        <th   style="text-align:center;  font-size:16px;">文献原文上传</th>
      </tr>
      <tr>
      	<td>
      		<div id="fileQueue_pdf" align="center"> 
              <input id="pdf_upload" name="pdf_upload" type="file" />	&nbsp;&nbsp;
              <input id="paperid" name="paperid" type="hidden" value="" />	&nbsp;&nbsp;
              <input type="button" onclick="jQuery('#pdf_upload').uploadifyUpload()" value="开始上传" class="butto"/> 
              <input type="button" onclick="jQuery('#pdf_upload').uploadifyClearQueue()" value="取消上传" class="butto"/>
            </div>
      	</td>
      	</tr>
      	<tr>
      	<td>
      		<font color=red>操作说明：</font><br>
      		上传原文附件时，请先在左侧数据列表选择原文对应的条目，具体操作步骤如下:</br>
      		<br>
      		1、选择要上传附件的条目;</br>
      		<br>
      		2、选择要传的原文;</br>
      		<br>
      		3、上传;</br>
      	</td>
      </tr>
    </table>
</body>
</html>
